//
// GPSMapEdit
// (c) Konstantin Galichsky (kg@geopainting.com), 2002-2007
//
// 'File|New' command.
//

# include "StdAfx.h"
# include "Map.h"
# include "UndoRedo.h"
# include "Log.h"
# include "Menu.h"
# include "RecentFiles.h"
# include "Status.h"
# include "Save.h"
# include "NewMap.h"
# include "Scale.h"
# include "Position.h"
# include "MapView.h"
# include "MiniMap.h"
# include "Position.h"
# include "Selection.h"
# include "Tool.h"
# include "VerifyMap.h"
# include "Globals.h"

bool RemoveMap () {
	if (! RequestSave ())
		return false;

	SaveRecentMapPosition ();

	ResetVerifyMapResults ();

	ResetUndoRedo ();
	g_bModified = false;
	g_bHaveWaypointsOrTracks = false;

	// Update title.
	g_strFileName [0] = '\0';
	UpdateTitle ();

	// Disable mini-window.
	g_lMiniW = 0;
	g_lMiniH = 0;
	::SetWindowPos (g_hMiniMapWnd, NULL, 0, 0, g_lMiniW, g_lMiniH, SWP_NOMOVE | SWP_NOZORDER);

	ResetStatus ();
	{
		CWaiter w;
		CCritSec::CLock lock (g_cs);
		g_map.clear ();
		g_Selection.clear ();
	}
	CTool::_OnRemoveMap ();
	RefreshScales ();
	Refresh ();

	ClearLog ();

	UpdateMenu ();

	return true;
}
